package com.example.getaudit.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.getaudit.entity.CommodityMarketPriceMonthly;
import com.example.getaudit.service.CommodityMarketPriceMonthlyService;
import java.io.IOException;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import static com.example.getaudit.pojo.CommonResult.success;
import jakarta.validation.Valid;
import com.example.getaudit.pojo.CommonResult;
import lombok.RequiredArgsConstructor;
/**
 * 商品区域参考价月表
 *
 * @author 
 * @since 2025/03/18
 */
@Slf4j
@RestController
@RequestMapping("/commodityMarketPriceMonthly")
@RequiredArgsConstructor
public class CommodityMarketPriceMonthlyController {

    private final  CommodityMarketPriceMonthlyService commodityMarketPriceMonthlyService;
    
    /**
     * 新增
     *
     * @param  CommodityMarketPriceMonthly  createVO 创建VO
     * @return id
     */
    @PostMapping
    public CommonResult<Long> create(@RequestBody @Valid CommodityMarketPriceMonthly createVO) {
        return success(commodityMarketPriceMonthlyService.create(createVO));
    }
    
    /**
     * 更新
     *
     * @param CommodityMarketPriceMonthly updateVO 更新VO
     * @return true/false
     */
    @PutMapping
    public CommonResult<Boolean> update(@RequestBody @Valid CommodityMarketPriceMonthly updateVO) {
            commodityMarketPriceMonthlyService.update(updateVO);
        return success(true);
    }
    
    /**
     * 删除
     *
     * @param id id
     * @return true/false
     */
    @DeleteMapping
    public CommonResult<Boolean> delete(@RequestParam("id") Long id) {
        commodityMarketPriceMonthlyService.delete(id);
        return success(true);
    }
    
    /**
     * 查询单个
     *
     * @param id id
     * @return vo
     */
    @GetMapping("/{id}")
    public CommonResult<CommodityMarketPriceMonthly> get(@PathVariable("id") Long id) {
        return success(commodityMarketPriceMonthlyService.get(id));
    }


}
